package top.scsoul.pas.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import top.scsoul.pas.entity.Achievement;

import java.util.List;

@Repository
public interface AchievementRepository extends JpaRepository<Achievement, Long> {
    /**
     * 根据考试id 获取成绩表
     *
     * @param id
     * @return
     */
    @Query(value = "select * from achievement where exam_info_id = ?1", nativeQuery = true)
    List<Achievement> listAchievementByExamInfoId(Long id);

    @Modifying
    @Query(value = "delete from achievement where student_id =?1", nativeQuery = true)
    void delByStudentId(Long id);

    /**
     * 根据考试id删除成绩表的一些信息
     *
     * @param id
     */
    @Modifying
    @Query(value = "delete from achievement where exam_info_id =?1", nativeQuery = true)
    void delByExamInfo(Long id);
}
